package br.unicamp.ic.lis.dbvservice.resource;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import br.unicamp.ic.lis.docseaservice.resource.PingResource;
import br.unicamp.ic.lis.docseaservice.utils.PropertiesUtils;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;

public class PingResourceIT {

	private static final String BASE_URI = "http://localhost:"
			+ PropertiesUtils.getString("glassfish.test.port")
			+ "/fnjvservice/resources";

	@Test
	public void getTest() {
		Client client = Client.create();
		WebResource webResource = client.resource(BASE_URI + "/ping");
		ClientResponse response = webResource.accept("text/plain").get(
				ClientResponse.class);
		int status = response.getStatus();
		String result = response.getEntity(String.class);
		assertEquals(200, status);
		assertEquals(PingResource.PING_RESPONSE_MESSAGE, result);
	}

}
